<template>
  <div class="tabbar">
    <ul>
      <li @click="changeRoute('home')">
        <img v-if="active == 'home'" src="../assets/tabbar/icon-home-d.png" alt="" />
        <img v-else src="../assets/tabbar/icon-home.png" alt="">
        <span :class="[active == 'home' ? 'active' : '']">首页</span>
      </li>
      <!-- <li @click="changeRoute('distribution')"> -->
      <li @click="changeRoute('distribution')" v-if="this.role != '二级分销商'">
        <img v-if="active == 'distribution'" src="../assets/tabbar/icon-retail-d.png" alt="" />
        <img v-else src="../assets/tabbar/icon-retail.png" alt="">
        <span :class="[active == 'distribution' ? 'active' : '']">分销</span>
      </li>
      <li @click="changeRoute('order')">
        <img v-if="active == 'order'" src="../assets/tabbar/icon-order-d.png" alt="" />
        <img v-else src="../assets/tabbar/icon-order.png" alt="">
        <span :class="[active == 'order' ? 'active' : '']">订单</span>
      </li>
    </ul>
  </div>
</template>

<script>
export default {
  name:'tabbar',
  data() {
    return {
      active: "",
      role:"", // 分销商
    };
  },
  created(){
    this.active = this.$route.path.split('/')[1];
    this.role = this.$store.state.role;
  },
  methods: {
    changeRoute(route){
        this.active = route;
        // console.log('this.active',this.active)
        this.$router.push('/' + route);
    }
  },
};
</script>

<style lang="scss" scoped>
.tabbar {
  width: 100%;
  height: 102px;
  position: fixed;
  left: 0;
  bottom: -2px;
  background-color: #fff;
  ul {
    height: 102px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    li {
      flex: 1;
      display: flex;
      flex-direction: column;
      align-items: center;
      justify-content: center;
      img {
        width: 40px;
        height: 38px;
        margin-bottom: 14px;
      }
      span {
        color: #909090;
      }
    }

    .active {
      font-weight: bold;
      color: #101010;
    }
  }
}
</style>